﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace QuanLyKhachHang.Data
{
    class TTChiTiet
    {
        public string MaChiTiet, MaKhachHang, NguoiLienHe, ChucVu, DiaChi, DienThoai, DiDong, Email, GhiChu;
        public DateTime NgaySinh;
        public TTChiTiet() { }
        public TTChiTiet(string MaChiTiet, string MaKhachHang, string NguoiLienHe, string ChucVu,DateTime NgaySinh, string DiaChi, string DienThoai, string DiDong, string Email, string GhiChu)
        {
            this.MaChiTiet = MaChiTiet;
            this.MaKhachHang = MaKhachHang;
            this.NguoiLienHe = NguoiLienHe;
            this.ChucVu = ChucVu;
            this.NgaySinh = NgaySinh;
            this.DiaChi = DiaChi;
            this.DienThoai = DienThoai;
            this.DiDong = DiDong;
            this.Email = Email;
            this.GhiChu = GhiChu;
        }
    }
    class NVChiTiet
    {
        public static DataTable ChonTatCa()
        {
            return Connect.cnSQL.ExecQuery("Select * from ChiTiet");
        }
        public static DataTable ChonTatCa(string MaKhachHang)
        {
            return Connect.cnSQL.ExecQuery("Select * from ChiTiet where MaKhachHang='" + MaKhachHang + "'");
        }
        public static bool Them(TTChiTiet ChiTiet)
        {
            Connect.cnSQL.ExecNonQuery("Insert into ChiTiet values('" + ChiTiet.MaChiTiet + "','" + ChiTiet.MaKhachHang + "',N'" + ChiTiet.NguoiLienHe + "',N'" + ChiTiet.ChucVu +  "',N'" + ChiTiet.DiaChi + "','" + ChiTiet.DienThoai + "','" + ChiTiet.DiDong + "',N'" + ChiTiet.Email + "')");
            return (!Connect.Tools.CoLoi);
        }
        public static bool Sua(TTChiTiet ChiTiet)
        {
            Connect.cnSQL.ExecNonQuery("Update ChiTiet Set MaKhachHang='" + ChiTiet.MaKhachHang + "', NguoiLienHe=N'" + ChiTiet.NguoiLienHe + "', ChucVu=N'" + ChiTiet.ChucVu + "', DiaChi=N'" + ChiTiet.DiaChi + "',DienThoai='" + ChiTiet.DienThoai + "', DiDong='" + ChiTiet.DiDong + "', Email=N'" + ChiTiet.Email + "'  where MaChiTiet='" + ChiTiet.MaChiTiet + "'");
            return (!Connect.Tools.CoLoi);
        }
        public static bool Xoa(string MaChiTiet)
        {
            Connect.cnSQL.ExecNonQuery("Delete ChiTiet where MaChiTiet ='" + MaChiTiet + "'");
            return (!Connect.Tools.CoLoi);
        }
    }
}
